package com.project.zsxd.server.clocksleep.service;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.zsxd.server.clocksleep.entity.ClockSleep;
import com.baomidou.mybatisplus.extension.service.IService;
import com.project.zsxd.server.clocksleep.vo.ClockSleepVO;
import com.project.zsxd.server.user.entity.User;

import java.time.LocalDate;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 睡眠打卡表 服务类
 * </p>
 *
 * @author kaler
 * @since 2020-09-23
 */
public interface IClockSleepService extends IService<ClockSleep> {

    /**
     * 计算入睡日期
     * @param sleepTime
     * @return
     */
    String calSleepDate(Date sleepTime);
    /**
     * 打卡入睡
     * @param user
     * @return
     */
    ClockSleep startSleep(User user);

    /**
     * 补打卡
     * @param currentUser 用户
     * @param clockSleepVO 打卡时间
     * @return
     */
    ClockSleep fillSleep(User currentUser, ClockSleepVO clockSleepVO);

    /**
     * 分页查询最近一个月的入睡时间
     * @return
     */
    List<ClockSleepVO> queryLastMonthSleepTimes();
    JSONObject queryLastMonthSleepTimesOld();

    /**
     * 查询是否已入睡
     * @param user
     * @return
     */
    boolean queryIsSleepping(User user);

    /**
     * 指定日期是否已打卡
     * @param user
     * @param sleepDate
     * @return
     */
    boolean queryIsSleepping(User user, String sleepDate);

}
